package cn.nawang.ebeim.client.bean;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

/**
 * @ClassName: LocalBackupQueue
 * @Description: 本地备份队列
 * @author 张建峰
 * @date 2015年9月17日 上午11:41:47
 * @version v1.0
 */
public class LocalBackupQueue {

  private static BlockingQueue<LocalBackupTask> backupTaskQueue =
      new ArrayBlockingQueue<LocalBackupTask>(ClientConfiguration.getQueueSize());

  public static BlockingQueue<LocalBackupTask> getBackupTaskQueue() {
    return backupTaskQueue;
  }

  public static void enqueue(LocalBackupTask task) throws InterruptedException {
    backupTaskQueue.put(task);
  }

  public static LocalBackupTask dequeue() throws InterruptedException {
    return backupTaskQueue.take();
  }

  public static boolean isEmpty() {
    return backupTaskQueue.isEmpty();
  }
}
